#include "myprocesswin.h"
#include "ui_myprocesswin.h"
#include <QDebug>
MyProcessWin::MyProcessWin(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MyProcessWin)
{
    ui->setupUi(this);
    //关联进程完成信号  finished(int exitCode,QProcess::ExitStatus exitStatus)
    //关联方式  旧的关联方式
    connect(&mprocess,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(start_process(int,QProcess::ExitStatus)));

}

MyProcessWin::~MyProcessWin()
{
    delete ui;
}

void MyProcessWin::on_calcBt_clicked()
{
    //启动取色器
    mprocess.start("C:/Users/asus/Desktop/TakeColor.exe");
}

void MyProcessWin::on_noteBt_clicked()
{
    if(mprocess.state()==QProcess::Running){  //进程正在运行中
        mprocess.kill();  //杀死进程  -- 要有一个过程
        //mprocess.waitForFinished(1000);   //阻塞--最长时间1000ms
    }

    //启动金山打字通
    mprocess.start("D:/Typeeasy/TypeEasy.exe");
}

void MyProcessWin::start_process(int exitCode,QProcess::ExitStatus exitStatus)
{
    qDebug()<<exitCode<<exitStatus;
}
